<!DOCTYPE html>
<html lang="zh" dir="ltr" class="client-nojs">
<head>
<title>伪随机数生成</title>
<meta charset="UTF-8">
<meta name="generator" content="MediaWiki 1.21.2">
<link rel="shortcut icon" href="../../../common/favicon.ico">
<link rel="stylesheet" href="../../../common/ext.css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" href="../../../common/site_modules.css">
<style>a:lang(ar),a:lang(ckb),a:lang(fa),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}#toc{display:none}.editsection{display:none}
/* cache key: mwiki1-mwiki_zh_:resourceloader:filter:minify-css:7:15cea3ec788a65b5187d4018eed543bf */</style>

<script src="../../../common/startup_scripts.js"></script>
<script>if(window.mw){
mw.config.set({"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"cpp/numeric/random","wgTitle":"cpp/numeric/random","wgCurRevisionId":61773,"wgArticleId":3155,"wgIsArticle":true,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":[],"wgBreakFrames":false,"wgPageContentLanguage":"zh","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"zh","wgMonthNames":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"wgMonthNamesShort":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"wgRelevantPageName":"cpp/numeric/random","wgUserVariant":"zh","wgRestrictionEdit":[],"wgRestrictionMove":[]});
}</script><script>if(window.mw){
mw.loader.implement("user.options",function(){mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"disablesuggest":0,"editfont":"default","editondblclick":0,"editsection":0,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"externaldiff":0,"externaleditor":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"imagesize":2,"justify":0,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nocache":0,"noconvertlink":0,"norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"quickbar":5,"rcdays":7,"rclimit":50,"rememberpassword":0,"rows":25,"searchlimit":20,"showhiddencats":0,"showjumplinks":1,"shownumberswatching":1,"showtoc":0,"showtoolbar":1,"skin":"cppreference2","stubthreshold":0,"thumbsize":2,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":0,"watchdefault":0,"watchdeletion":0,
"watchlistdays":3,"watchlisthideanons":0,"watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,"variant":"zh","language":"zh","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false,"gadget-MathJax":1,"gadget-ColiruCompiler":1});;},{},{});mw.loader.implement("user.tokens",function(){mw.user.tokens.set({"editToken":"+\\","patrolToken":false,"watchToken":false});;},{},{});
/* cache key: mwiki1-mwiki_zh_:resourceloader:filter:minify-js:7:258d7cd6aa9aa67dee25e01fb6a9e505 */
}</script>
<script>if(window.mw){
mw.loader.load(["mediawiki.page.startup","mediawiki.legacy.wikibits","mediawiki.legacy.ajax"]);
}</script>
<style type="text/css">/*<![CDATA[*/
.source-cpp {line-height: normal;}
.source-cpp li, .source-cpp pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for cpp
 * CSS class: source-cpp, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.cpp.source-cpp .de1, .cpp.source-cpp .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.cpp.source-cpp  {font-family:monospace;}
.cpp.source-cpp .imp {font-weight: bold; color: red;}
.cpp.source-cpp li, .cpp.source-cpp .li1 {font-weight: normal; vertical-align:top;}
.cpp.source-cpp .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.cpp.source-cpp .li2 {font-weight: bold; vertical-align:top;}
.cpp.source-cpp .kw1 {color: #0000dd;}
.cpp.source-cpp .kw2 {color: #0000ff;}
.cpp.source-cpp .kw3 {color: #0000dd;}
.cpp.source-cpp .kw4 {color: #0000ff;}
.cpp.source-cpp .co1 {color: #909090;}
.cpp.source-cpp .co2 {color: #339900;}
.cpp.source-cpp .coMULTI {color: #ff0000; font-style: italic;}
.cpp.source-cpp .es0 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es1 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es2 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es3 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es4 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es5 {color: #008000; font-weight: bold;}
.cpp.source-cpp .br0 {color: #008000;}
.cpp.source-cpp .sy0 {color: #008000;}
.cpp.source-cpp .sy1 {color: #000080;}
.cpp.source-cpp .sy2 {color: #000040;}
.cpp.source-cpp .sy3 {color: #000040;}
.cpp.source-cpp .sy4 {color: #008080;}
.cpp.source-cpp .st0 {color: #008000;}
.cpp.source-cpp .nu0 {color: #000080;}
.cpp.source-cpp .nu6 {color: #000080;}
.cpp.source-cpp .nu8 {color: #000080;}
.cpp.source-cpp .nu12 {color: #000080;}
.cpp.source-cpp .nu16 {color:#000080;}
.cpp.source-cpp .nu17 {color:#000080;}
.cpp.source-cpp .nu18 {color:#000080;}
.cpp.source-cpp .nu19 {color:#000080;}
.cpp.source-cpp .ln-xtra, .cpp.source-cpp li.ln-xtra, .cpp.source-cpp div.ln-xtra {background-color: #ffc;}
.cpp.source-cpp span.xtra { display:block; }

/*]]>*/
</style><style type="text/css">/*<![CDATA[*/
.source-text {line-height: normal;}
.source-text li, .source-text pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for text
 * CSS class: source-text, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.text.source-text .de1, .text.source-text .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.text.source-text  {font-family:monospace;}
.text.source-text .imp {font-weight: bold; color: red;}
.text.source-text li, .text.source-text .li1 {font-weight: normal; vertical-align:top;}
.text.source-text .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.text.source-text .li2 {font-weight: bold; vertical-align:top;}
.text.source-text .ln-xtra, .text.source-text li.ln-xtra, .text.source-text div.ln-xtra {background-color: #ffc;}
.text.source-text span.xtra { display:block; }

/*]]>*/
</style><!--[if lt IE 7]><style type="text/css">body{behavior:url("/mwiki/skins/cppreference2/csshover.min.htc")}</style><![endif]--></head>
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-cpp_numeric_random skin-cppreference2 action-view cpp-navbar">
        <!-- header -->
        <!-- /header -->
        <!-- content -->
<div id="cpp-content-base">
            <div id="content">
                <a id="top"></a>
                <div id="mw-js-message" style="display:none;"></div>
                                <!-- firstHeading -->
<h1 id="firstHeading" class="firstHeading">伪随机数生成</h1>
                <!-- /firstHeading -->
                <!-- bodyContent -->
                <div id="bodyContent">
                                        <!-- tagline -->
                    <div id="siteSub">来自cppreference.com</div>
                    <!-- /tagline -->
                                        <!-- subtitle -->
                    <div id="contentSub"><span class="subpages">&lt; <a href="../../cpp.html" title="cpp">cpp</a>‎ | <a href="../numeric.html" title="cpp/numeric">numeric</a></span></div>
                    <!-- /subtitle -->
                                                            <!-- bodycontent -->
                    <div id="mw-content-text" lang="zh" dir="ltr" class="mw-content-ltr"><div class="t-navbar" style=""><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../../cpp.html" title="cpp"> C++</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="line-height:1.1em;">
<tr class="t-nv"><td colspan="5"> <a href="../language.html" title="cpp/language">语言</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../header.html" title="cpp/header">标准库头文件</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../freestanding.html" title="cpp/freestanding"> 自立与有宿主实现</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../named_req.html" title="cpp/named req">具名要求</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../utility.html#.E8.AF.AD.E8.A8.80.E6.94.AF.E6.8C.81" title="cpp/utility">语言支持库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../concepts.html" title="cpp/concepts">概念库</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../error.html" title="cpp/error">诊断库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../utility.html" title="cpp/utility">工具库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../string.html" title="cpp/string">字符串库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="https://zh.cppreference.com/w/cpp/container" title="cpp/container">容器库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../iterator.html" title="cpp/iterator">迭代器库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../ranges.html" title="cpp/ranges"> 范围库</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../algorithm.html" title="cpp/algorithm">算法库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../numeric.html" title="cpp/numeric">数值库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../io.html" title="cpp/io">输入/输出库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../locale.html" title="cpp/locale">本地化库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../regex.html" title="cpp/regex">正则表达式库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../atomic.html" title="cpp/atomic">原子操作库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../thread.html" title="cpp/thread">线程支持库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../filesystem.html" title="cpp/filesystem">文件系统库</a> <span class="t-mark-rev t-since-cxx17">(C++17)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../experimental.html" title="cpp/experimental">技术规范</a> </td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../numeric.html" title="cpp/numeric">数值库</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="math.html" title="cpp/numeric/math">常用数学函数</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="special_functions.html" title="cpp/numeric/special functions">数学特殊函数</a> <span class="t-mark-rev t-since-cxx17">(C++17)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="constants.html" title="cpp/numeric/constants">数学常数</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="fenv.html" title="cpp/numeric/fenv">浮点环境</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="complex.html" title="cpp/numeric/complex">复数</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="valarray.html" title="cpp/numeric/valarray">数值数组</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <strong class="selflink">伪随机数生成</strong> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="ratio.html" title="cpp/numeric/ratio">编译时有理数算术</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv-h2"><td colspan="5">数值算法</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="gcd.html" title="cpp/numeric/gcd"><span class="t-lines"><span>gcd</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="lcm.html" title="cpp/numeric/lcm"><span class="t-lines"><span>lcm</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5">插值</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="midpoint.html" title="cpp/numeric/midpoint"><span class="t-lines"><span>midpoint</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="lerp.html" title="cpp/numeric/lerp"><span class="t-lines"><span>lerp</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5">通用数值运算</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../algorithm/iota.html" title="cpp/algorithm/iota"><span class="t-lines"><span>iota</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../algorithm/accumulate.html" title="cpp/algorithm/accumulate"><span class="t-lines"><span>accumulate</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../algorithm/inner_product.html" title="cpp/algorithm/inner product"><span class="t-lines"><span>inner_product</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../algorithm/adjacent_difference.html" title="cpp/algorithm/adjacent difference"><span class="t-lines"><span>adjacent_difference</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../algorithm/partial_sum.html" title="cpp/algorithm/partial sum"><span class="t-lines"><span>partial_sum</span></span></a></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5">位操作</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="bit_cast.html" title="cpp/numeric/bit cast"><span class="t-lines"><span>bit_cast</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="has_single_bit.html" title="cpp/numeric/has single bit"><span class="t-lines"><span>has_single_bit</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="bit_ceil.html" title="cpp/numeric/bit ceil"><span class="t-lines"><span>bit_ceil</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="bit_floor.html" title="cpp/numeric/bit floor"><span class="t-lines"><span>bit_floor</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="bit_width.html" title="cpp/numeric/bit width"><span class="t-lines"><span>bit_width</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="rotl.html" title="cpp/numeric/rotl"><span class="t-lines"><span>rotl</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="rotr.html" title="cpp/numeric/rotr"><span class="t-lines"><span>rotr</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="countl_zero.html" title="cpp/numeric/countl zero"><span class="t-lines"><span>countl_zero</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="countl_one.html" title="cpp/numeric/countl one"><span class="t-lines"><span>countl_one</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="countr_zero.html" title="cpp/numeric/countr zero"><span class="t-lines"><span>countr_zero</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="countr_one.html" title="cpp/numeric/countr one"><span class="t-lines"><span>countr_one</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="popcount.html" title="cpp/numeric/popcount"><span class="t-lines"><span>popcount</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../types/endian.html" title="cpp/types/endian"><span class="t-lines"><span>endian</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><strong class="selflink">伪随机数生成</strong><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h1"><td colspan="5"> 均匀随机位生成器</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/uniform_random_bit_generator.html" title="cpp/numeric/random/uniform random bit generator"><span class="t-lines"><span>uniform_random_bit_generator</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 引擎及引擎适配器</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/linear_congruential_engine.html" title="cpp/numeric/random/linear congruential engine"><span class="t-lines"><span>linear_congruential_engine</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/mersenne_twister_engine.html" title="cpp/numeric/random/mersenne twister engine"><span class="t-lines"><span>mersenne_twister_engine</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/subtract_with_carry_engine.html" title="cpp/numeric/random/subtract with carry engine"><span class="t-lines"><span>subtract_with_carry_engine</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/discard_block_engine.html" title="cpp/numeric/random/discard block engine"><span class="t-lines"><span>discard_block_engine</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/independent_bits_engine.html" title="cpp/numeric/random/independent bits engine"><span class="t-lines"><span>independent_bits_engine</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/shuffle_order_engine.html" title="cpp/numeric/random/shuffle order engine"><span class="t-lines"><span>shuffle_order_engine</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 非确定性生成器</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/random_device.html" title="cpp/numeric/random/random device"><span class="t-lines"><span>random_device</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 分布</td></tr>
<tr class="t-nv-h2"><td colspan="5"> 均匀分布</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/uniform_int_distribution.html" title="cpp/numeric/random/uniform int distribution"><span class="t-lines"><span>uniform_int_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/uniform_real_distribution.html" title="cpp/numeric/random/uniform real distribution"><span class="t-lines"><span>uniform_real_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/generate_canonical.html" title="cpp/numeric/random/generate canonical"><span class="t-lines"><span>generate_canonical</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 伯努利分布</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/bernoulli_distribution.html" title="cpp/numeric/random/bernoulli distribution"><span class="t-lines"><span>bernoulli_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/binomial_distribution.html" title="cpp/numeric/random/binomial distribution"><span class="t-lines"><span>binomial_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/negative_binomial_distribution.html" title="cpp/numeric/random/negative binomial distribution"><span class="t-lines"><span>negative_binomial_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/geometric_distribution.html" title="cpp/numeric/random/geometric distribution"><span class="t-lines"><span>geometric_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 泊松分布</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/poisson_distribution.html" title="cpp/numeric/random/poisson distribution"><span class="t-lines"><span>poisson_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/exponential_distribution.html" title="cpp/numeric/random/exponential distribution"><span class="t-lines"><span>exponential_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/gamma_distribution.html" title="cpp/numeric/random/gamma distribution"><span class="t-lines"><span>gamma_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/weibull_distribution.html" title="cpp/numeric/random/weibull distribution"><span class="t-lines"><span>weibull_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/extreme_value_distribution.html" title="cpp/numeric/random/extreme value distribution"><span class="t-lines"><span>extreme_value_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 正态分布</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/normal_distribution.html" title="cpp/numeric/random/normal distribution"><span class="t-lines"><span>normal_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/lognormal_distribution.html" title="cpp/numeric/random/lognormal distribution"><span class="t-lines"><span>lognormal_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/chi_squared_distribution.html" title="cpp/numeric/random/chi squared distribution"><span class="t-lines"><span>chi_squared_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/cauchy_distribution.html" title="cpp/numeric/random/cauchy distribution"><span class="t-lines"><span>cauchy_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/fisher_f_distribution.html" title="cpp/numeric/random/fisher f distribution"><span class="t-lines"><span>fisher_f_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/student_t_distribution.html" title="cpp/numeric/random/student t distribution"><span class="t-lines"><span>student_t_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 采样分布</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/discrete_distribution.html" title="cpp/numeric/random/discrete distribution"><span class="t-lines"><span>discrete_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/piecewise_constant_distribution.html" title="cpp/numeric/random/piecewise constant distribution"><span class="t-lines"><span>piecewise_constant_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/piecewise_linear_distribution.html" title="cpp/numeric/random/piecewise linear distribution"><span class="t-lines"><span>piecewise_linear_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 种子序列</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/seed_seq.html" title="cpp/numeric/random/seed seq"><span class="t-lines"><span>seed_seq</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> C 库</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/rand.html" title="cpp/numeric/random/rand"><span class="t-lines"><span>rand</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/srand.html" title="cpp/numeric/random/srand"><span class="t-lines"><span>srand</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random/RAND_MAX.html" title="cpp/numeric/random/RAND MAX"><span class="t-lines"><span>RAND_MAX</span></span></a></div></div></td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div></div>
<p>随机数库提供生成随机和伪随机数的类。这些类包括：
</p>
<ul><li> 均匀随机位生成器 (URBG) ，包含随机数引擎，它们是伪随机数生成器，生成拥有均匀分布整数序列的伪随机数生成器，以及真随机数生成器，若可用。
</li><li> 随机数分布（例如<a href="random/uniform_int_distribution.html" title="cpp/numeric/random/uniform int distribution">均匀</a>、<a href="random/normal_distribution.html" title="cpp/numeric/random/normal distribution">正态</a>或<a href="random/poisson_distribution.html" title="cpp/numeric/random/poisson distribution">泊松分布</a>），它们将 URBG 的输出转换为各种统计分布。
</li></ul>
<p>URBG 和分布被设计为相互使用以生成随机值。所有随机数引擎都可以指定地播种、序列化和反序列化，以用于可重复的模拟器。
</p>
<h3><span class="mw-headline" id=".E5.9D.87.E5.8C.80.E9.9A.8F.E6.9C.BA.E4.BD.8D.E7.94.9F.E6.88.90.E5.99.A8">均匀随机位生成器</span></h3>
<p><i>均匀随机位生成器</i>是函数对象，它返回无符号整数值，并使得每个值在可能结果的范围中拥有（理想上）相等的被返回概率。
</p><p>所有均匀随机位生成器都满足<a href="../named_req/UniformRandomBitGenerator.html" title="cpp/named req/UniformRandomBitGenerator"><i>均匀随机位生成器</i> <span style="font-family: Georgia, 'DejaVu Serif', serif; font-style:italic">(UniformRandomBitGenerator)</span> </a>要求。
C++20 亦定义 <a href="random/uniform_random_bit_generator.html" title="cpp/numeric/random/uniform random bit generator"><tt>uniform_random_bit_generator</tt></a> 概念。
</p>
<table class="t-dsc-begin">

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;random&gt;</code> </div>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/uniform_random_bit_generator.html" title="cpp/numeric/random/uniform random bit generator"> <span class="t-lines"><span>uniform_random_bit_generator</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  指定类型具备作为均匀随机位生成器的资格 <br> <span class="t-mark">(概念)</span> </td></tr>
</table>
<h4><span class="mw-headline" id=".E9.9A.8F.E6.9C.BA.E6.95.B0.E5.BC.95.E6.93.8E">随机数引擎</span></h4>
<p>随机数引擎以种子数据为熵源生成伪随机数。数种不同类的伪随机数生成算法实现为能定制的模板。
</p><p>选择使用何种引擎涉及到多次权衡：线性同余引擎一般地快，并对状态的存储要求非常小。延迟斐波那契生成器在无先进算术指令集的处理器上非常快，但状态存储较为庞大，有时有不太想要的光谱特性。梅森缠绕器较慢且拥有较大的状态存储要求，但只要有正确的参数，就会有最长的的不可重复序列，且拥有最想要的光谱特性（对于给定的想要的定义）。
</p>
<table class="t-dsc-begin">

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;random&gt;</code> </div>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/linear_congruential_engine.html" title="cpp/numeric/random/linear congruential engine"> <span class="t-lines"><span>linear_congruential_engine</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  实现<a href="https://en.wikipedia.org/wiki/Linear_congruential_generator" class="extiw" title="enwiki:Linear congruential generator">线性同余</a>算法 <br> <span class="t-mark">(类模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/mersenne_twister_engine.html" title="cpp/numeric/random/mersenne twister engine"> <span class="t-lines"><span>mersenne_twister_engine</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  实现<a href="https://en.wikipedia.org/wiki/Mersenne_twister" class="extiw" title="enwiki:Mersenne twister">梅森缠绕器</a>算法 <br> <span class="t-mark">(类模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/subtract_with_carry_engine.html" title="cpp/numeric/random/subtract with carry engine"> <span class="t-lines"><span>subtract_with_carry_engine</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  实现带进位减（一种<a href="https://en.wikipedia.org/wiki/Lagged_Fibonacci_generator" class="extiw" title="enwiki:Lagged Fibonacci generator">延迟斐波那契</a>）算法 <br> <span class="t-mark">(类模板)</span> </td></tr>
</table>
<h4><span class="mw-headline" id=".E9.9A.8F.E6.9C.BA.E6.95.B0.E5.BC.95.E6.93.8E.E9.80.82.E9.85.8D.E5.99.A8">随机数引擎适配器</span></h4>
<p>随机数引擎适配器生成以另一随机数引擎为熵源的伪随机数。它们通常用于改换底层引擎的光谱特性。
</p>
<table class="t-dsc-begin">

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;random&gt;</code> </div>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/discard_block_engine.html" title="cpp/numeric/random/discard block engine"> <span class="t-lines"><span>discard_block_engine</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  舍弃随机数引擎的某些输出 <br> <span class="t-mark">(类模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/independent_bits_engine.html" title="cpp/numeric/random/independent bits engine"> <span class="t-lines"><span>independent_bits_engine</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  将一个随机数引擎的输出打包为指定位数的块 <br> <span class="t-mark">(类模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/shuffle_order_engine.html" title="cpp/numeric/random/shuffle order engine"> <span class="t-lines"><span>shuffle_order_engine</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  以不同顺序发送一个随机数引擎的输出 <br> <span class="t-mark">(类模板)</span> </td></tr>
</table>
<h4><span class="mw-headline" id=".E9.A2.84.E5.AE.9A.E4.B9.89.E9.9A.8F.E6.9C.BA.E6.95.B0.E7.94.9F.E6.88.90.E5.99.A8">预定义随机数生成器</span></h4>
<p>定义了数个特别的流行算法。
</p>
<table class="t-dsc-begin">

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;random&gt;</code> </div>
</td></tr>

<tr class="t-dsc-sep">
<td colspan="2">  
</td></tr>
<tr class="t-dsc-hitem">
<td> 类型
</td>
<td> 定义
</td></tr>


<tr class="t-dsc">
<td>  <code>minstd_rand0</code><span class="t-mark-rev t-since-cxx11">(C++11)</span>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="random/linear_congruential_engine.html"><span class="kw1480">std::<span class="me2">linear_congruential_engine</span></span></a><span class="sy1">&lt;</span><a href="../types/integer.html"><span class="kw126">std::<span class="me2">uint_fast32_t</span></span></a>, <span class="nu0">16807</span>, <span class="nu0">0</span>, <span class="nu0">2147483647</span><span class="sy1">&gt;</span></span></span><br>
<p>由 Lewis、Goodman 及 Miller 发现于 1969，由 Park 与 Miller 于 1988 采纳为“最小标准”</p>
</td></tr>

<tr class="t-dsc">
<td>  <code>minstd_rand</code><span class="t-mark-rev t-since-cxx11">(C++11)</span>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="random/linear_congruential_engine.html"><span class="kw1480">std::<span class="me2">linear_congruential_engine</span></span></a><span class="sy1">&lt;</span><a href="../types/integer.html"><span class="kw126">std::<span class="me2">uint_fast32_t</span></span></a>, <span class="nu0">48271</span>, <span class="nu0">0</span>, <span class="nu0">2147483647</span><span class="sy1">&gt;</span></span></span><br>
<p>较新的“最小标准”，为 Park、 Miller 及 Stockmeyer 于 1993 推荐</p>
</td></tr>

<tr class="t-dsc">
<td>  <code>mt19937</code><span class="t-mark-rev t-since-cxx11">(C++11)</span>
</td>
<td>
<p><span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="random/mersenne_twister_engine.html"><span class="kw1481">std::<span class="me2">mersenne_twister_engine</span></span></a><span class="sy1">&lt;</span><a href="../types/integer.html"><span class="kw126">std::<span class="me2">uint_fast32_t</span></span></a>, <span class="nu0">32</span>, <span class="nu0">624</span>, <span class="nu0">397</span>, <span class="nu0">31</span>, <br>
                             <span class="nu12">0x9908b0df</span>, <span class="nu0">11</span>, <br>
                             <span class="nu12">0xffffffff</span>, <span class="nu0">7</span>, <br>
                             <span class="nu12">0x9d2c5680</span>, <span class="nu0">15</span>, <br>
                             <span class="nu12">0xefc60000</span>, <span class="nu0">18</span>, <span class="nu0">1812433253</span><span class="sy1">&gt;</span></span></span><br>
32 位梅森缠绕器，由松本与西村设计于 1998</p>
</td></tr>

<tr class="t-dsc">
<td>  <code>mt19937_64</code><span class="t-mark-rev t-since-cxx11">(C++11)</span>
</td>
<td>
<p><span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="random/mersenne_twister_engine.html"><span class="kw1481">std::<span class="me2">mersenne_twister_engine</span></span></a><span class="sy1">&lt;</span><a href="../types/integer.html"><span class="kw127">std::<span class="me2">uint_fast64_t</span></span></a>, <span class="nu0">64</span>, <span class="nu0">312</span>, <span class="nu0">156</span>, <span class="nu0">31</span>,<br>
                             <span class="nu12">0xb5026f5aa96619e9</span>, <span class="nu0">29</span>,<br>
                             <span class="nu12">0x5555555555555555</span>, <span class="nu0">17</span>,<br>
                             <span class="nu12">0x71d67fffeda60000</span>, <span class="nu0">37</span>,<br>
                             <span class="nu12">0xfff7eee000000000</span>, <span class="nu0">43</span>, <span class="nu0">6364136223846793005</span><span class="sy1">&gt;</span></span></span><br>
64 位梅森缠绕器，由松本与西村设计于 2000</p>
</td></tr>

<tr class="t-dsc">
<td>  <code>ranlux24_base</code><span class="t-mark-rev t-since-cxx11">(C++11)</span>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="random/subtract_with_carry_engine.html"><span class="kw1482">std::<span class="me2">subtract_with_carry_engine</span></span></a><span class="sy1">&lt;</span><a href="../types/integer.html"><span class="kw126">std::<span class="me2">uint_fast32_t</span></span></a>, <span class="nu0">24</span>, <span class="nu0">10</span>, <span class="nu0">24</span><span class="sy1">&gt;</span></span></span></td></tr>

<tr class="t-dsc">
<td>  <code>ranlux48_base</code><span class="t-mark-rev t-since-cxx11">(C++11)</span>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="random/subtract_with_carry_engine.html"><span class="kw1482">std::<span class="me2">subtract_with_carry_engine</span></span></a><span class="sy1">&lt;</span><a href="../types/integer.html"><span class="kw127">std::<span class="me2">uint_fast64_t</span></span></a>, <span class="nu0">48</span>, <span class="nu0">5</span>, <span class="nu0">12</span><span class="sy1">&gt;</span></span></span></td></tr>

<tr class="t-dsc">
<td>  <code>ranlux24</code><span class="t-mark-rev t-since-cxx11">(C++11)</span>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="random/discard_block_engine.html"><span class="kw1483">std::<span class="me2">discard_block_engine</span></span></a><span class="sy1">&lt;</span><a href="random/subtract_with_carry_engine.html"><span class="kw1491">std::<span class="me2">ranlux24_base</span></span></a>, <span class="nu0">223</span>, <span class="nu0">23</span><span class="sy1">&gt;</span></span></span><br>
<p>24 位 RANLUX 生成器，由 Martin Lüscher 与 Fred James 设计于 1994</p>
</td></tr>

<tr class="t-dsc">
<td>  <code>ranlux48</code><span class="t-mark-rev t-since-cxx11">(C++11)</span>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="random/discard_block_engine.html"><span class="kw1483">std::<span class="me2">discard_block_engine</span></span></a><span class="sy1">&lt;</span><a href="random/subtract_with_carry_engine.html"><span class="kw1492">std::<span class="me2">ranlux48_base</span></span></a>, <span class="nu0">389</span>, <span class="nu0">11</span><span class="sy1">&gt;</span></span></span><br>
<p>48 位 RANLUX 生成器，由 Martin Lüscher 与 Fred James 设计于 1994</p>
</td></tr>

<tr class="t-dsc">
<td>  <code>knuth_b</code><span class="t-mark-rev t-since-cxx11">(C++11)</span>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="random/shuffle_order_engine.html"><span class="kw1485">std::<span class="me2">shuffle_order_engine</span></span></a><span class="sy1">&lt;</span><a href="random/linear_congruential_engine.html"><span class="kw1487">std::<span class="me2">minstd_rand0</span></span></a>, <span class="nu0">256</span><span class="sy1">&gt;</span></span></span></td></tr>

<tr class="t-dsc">
<td>  <code>default_random_engine</code><span class="t-mark-rev t-since-cxx11">(C++11)</span>
</td>
<td>  <i>实现定义</i>
</td></tr>
</table>
<h4><span class="mw-headline" id=".E9.9D.9E.E7.A1.AE.E5.AE.9A.E9.9A.8F.E6.9C.BA.E6.95.B0">非确定随机数</span></h4>
<p><span class="t-lc"><a href="random/random_device.html" title="cpp/numeric/random/random device">std::random_device</a></span> 是非确定的均匀随机位生成器，尽管若不支持非确定随机数生成，则允许实现用伪随机数引擎实现 <span class="t-lc"><a href="random/random_device.html" title="cpp/numeric/random/random device">std::random_device</a></span> 。
</p>
<table class="t-dsc-begin">

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/random_device.html" title="cpp/numeric/random/random device"> <span class="t-lines"><span>random_device</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  使用硬件熵源的非确定随机数生成器 <br> <span class="t-mark">(类)</span> </td></tr>
</table>
<h3><span class="mw-headline" id=".E9.9A.8F.E6.9C.BA.E6.95.B0.E5.88.86.E5.B8.83">随机数分布</span></h3>
<p>随机数分布后处理 URBG 的输出，以使得输出结果按照定义的统计概率密度函数分布。
</p><p>随机数分布满足<a href="../named_req/RandomNumberDistribution.html" title="cpp/named req/RandomNumberDistribution"><i>随机数分布</i> <span style="font-family: Georgia, 'DejaVu Serif', serif; font-style:italic">(RandomNumberDistribution)</span> </a>
</p>
<table class="t-dsc-begin">

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;random&gt;</code> </div>
</td></tr>

<tr>
<td colspan="2"> <h5> <span class="mw-headline" id=".E5.9D.87.E5.8C.80.E5.88.86.E5.B8.83"> 均匀分布 </span></h5>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/uniform_int_distribution.html" title="cpp/numeric/random/uniform int distribution"> <span class="t-lines"><span>uniform_int_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  产生在一个范围上均匀分布的整数值 <br> <span class="t-mark">(类模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/uniform_real_distribution.html" title="cpp/numeric/random/uniform real distribution"> <span class="t-lines"><span>uniform_real_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  产生在一个范围上均匀分布的实数值 <br> <span class="t-mark">(类模板)</span> </td></tr>


<tr>
<td colspan="2"> <h5> <span class="mw-headline" id=".E4.BC.AF.E5.8A.AA.E5.88.A9.E5.88.86.E5.B8.83"> 伯努利分布 </span></h5>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/bernoulli_distribution.html" title="cpp/numeric/random/bernoulli distribution"> <span class="t-lines"><span>bernoulli_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  产生<a href="https://en.wikipedia.org/wiki/Bernoulli_distribution" class="extiw" title="enwiki:Bernoulli distribution">伯努利分布</a>上的 <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">bool</span></span></span> 值。 <br> <span class="t-mark">(类)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/binomial_distribution.html" title="cpp/numeric/random/binomial distribution"> <span class="t-lines"><span>binomial_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  产生<a href="https://en.wikipedia.org/wiki/Binomial_distribution" class="extiw" title="enwiki:Binomial distribution">二项分布</a>上的整数值。 <br> <span class="t-mark">(类模板)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/negative_binomial_distribution.html" title="cpp/numeric/random/negative binomial distribution"> <span class="t-lines"><span>negative_binomial_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  产生<a href="https://en.wikipedia.org/wiki/Negative_binomial_distribution" class="extiw" title="enwiki:Negative binomial distribution">负二项分布</a>上的整数值。 <br> <span class="t-mark">(类模板)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/geometric_distribution.html" title="cpp/numeric/random/geometric distribution"> <span class="t-lines"><span>geometric_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  产生<a href="https://en.wikipedia.org/wiki/Geometric_distribution" class="extiw" title="enwiki:Geometric distribution">几何分布</a>上的整数值。 <br> <span class="t-mark">(类模板)</span>
</td></tr>


<tr>
<td colspan="2"> <h5> <span class="mw-headline" id=".E6.B3.8A.E6.9D.BE.E5.88.86.E5.B8.83"> 泊松分布 </span></h5>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/poisson_distribution.html" title="cpp/numeric/random/poisson distribution"> <span class="t-lines"><span>poisson_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  产生<a href="https://en.wikipedia.org/wiki/Poisson_distribution" class="extiw" title="enwiki:Poisson distribution">泊松分布</a>上的整数值。 <br> <span class="t-mark">(类模板)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/exponential_distribution.html" title="cpp/numeric/random/exponential distribution"> <span class="t-lines"><span>exponential_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  产生<a href="https://en.wikipedia.org/wiki/Exponential_distribution" class="extiw" title="enwiki:Exponential distribution">指数分布</a>上的实数值。 <br> <span class="t-mark">(类模板)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/gamma_distribution.html" title="cpp/numeric/random/gamma distribution"> <span class="t-lines"><span>gamma_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  产生 <a href="https://en.wikipedia.org/wiki/Gamma_distribution" class="extiw" title="enwiki:Gamma distribution">Γ 分布</a>上的实数值 <br> <span class="t-mark">(类模板)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/weibull_distribution.html" title="cpp/numeric/random/weibull distribution"> <span class="t-lines"><span>weibull_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  产生<a href="https://en.wikipedia.org/wiki/Weibull_distribution" class="extiw" title="enwiki:Weibull distribution">威布尔分布</a>上的实数值。 <br> <span class="t-mark">(类模板)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/extreme_value_distribution.html" title="cpp/numeric/random/extreme value distribution"> <span class="t-lines"><span>extreme_value_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  产生<a href="https://en.wikipedia.org/wiki/Generalized_extreme_value_distribution" class="extiw" title="enwiki:Generalized extreme value distribution">极值分布</a>上的实数值。 <br> <span class="t-mark">(类模板)</span>
</td></tr>


<tr>
<td colspan="2"> <h5> <span class="mw-headline" id=".E6.AD.A3.E6.80.81.E5.88.86.E5.B8.83"> 正态分布 </span></h5>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/normal_distribution.html" title="cpp/numeric/random/normal distribution"> <span class="t-lines"><span>normal_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  产生<a href="https://en.wikipedia.org/wiki/Normal_distribution" class="extiw" title="enwiki:Normal distribution">标准正态（高斯）分布</a>上的实数值。 <br> <span class="t-mark">(类模板)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/lognormal_distribution.html" title="cpp/numeric/random/lognormal distribution"> <span class="t-lines"><span>lognormal_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  产生<a href="https://en.wikipedia.org/wiki/Lognormal_distribution" class="extiw" title="enwiki:Lognormal distribution">对数正态分布</a>上的实数值。 <br> <span class="t-mark">(类模板)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/chi_squared_distribution.html" title="cpp/numeric/random/chi squared distribution"> <span class="t-lines"><span>chi_squared_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  产生 <a href="https://en.wikipedia.org/wiki/Chi-squared_distribution" class="extiw" title="enwiki:Chi-squared distribution">χ<sup>2</sup> 分布上</a>上的实数值。 <br> <span class="t-mark">(类模板)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/cauchy_distribution.html" title="cpp/numeric/random/cauchy distribution"> <span class="t-lines"><span>cauchy_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  产生<a href="https://en.wikipedia.org/wiki/Cauchy_distribution" class="extiw" title="enwiki:Cauchy distribution">柯西分布</a>上的实数值。 <br> <span class="t-mark">(类模板)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/fisher_f_distribution.html" title="cpp/numeric/random/fisher f distribution"> <span class="t-lines"><span>fisher_f_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  产生<a href="https://en.wikipedia.org/wiki/F-distribution" class="extiw" title="enwiki:F-distribution">费舍尔 F 分布</a>上的实数值。 <br> <span class="t-mark">(类模板)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/student_t_distribution.html" title="cpp/numeric/random/student t distribution"> <span class="t-lines"><span>student_t_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  产生<a href="https://en.wikipedia.org/wiki/Student%27s_t-distribution" class="extiw" title="enwiki:Student's t-distribution">学生 t 分布</a>上的实数值。 <br> <span class="t-mark">(类模板)</span>
</td></tr>


<tr>
<td colspan="2"> <h5> <span class="mw-headline" id=".E9.87.87.E6.A0.B7.E5.88.86.E5.B8.83"> 采样分布 </span></h5>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/discrete_distribution.html" title="cpp/numeric/random/discrete distribution"> <span class="t-lines"><span>discrete_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  产生离散分布上的随机整数。 <br> <span class="t-mark">(类模板)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/piecewise_constant_distribution.html" title="cpp/numeric/random/piecewise constant distribution"> <span class="t-lines"><span>piecewise_constant_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  产生分布在常子区间上的实数值。 <br> <span class="t-mark">(类模板)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/piecewise_linear_distribution.html" title="cpp/numeric/random/piecewise linear distribution"> <span class="t-lines"><span>piecewise_linear_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  产生分布在定义的子区间上的实数值。 <br> <span class="t-mark">(类模板)</span>
</td></tr>
</table>
<h3><span class="mw-headline" id=".E5.B7.A5.E5.85.B7">工具</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;random&gt;</code> </div>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/generate_canonical.html" title="cpp/numeric/random/generate canonical"> <span class="t-lines"><span>generate_canonical</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  给定精度的均匀分布在 [0, 1) 上的实数值 <br> <span class="t-mark">(函数模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/seed_seq.html" title="cpp/numeric/random/seed seq"> <span class="t-lines"><span>seed_seq</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  通用的偏差消除的混淆种子序列生成器 <br> <span class="t-mark">(类)</span>
</td></tr>
</table>
<h3><span class="mw-headline" id="C_.E9.9A.8F.E6.9C.BA.E5.BA.93">C 随机库</span></h3>
<p>除了上述的引擎和分布，来自 C 随机库的函数和常量亦可用，尽管不推荐：
</p>
<table class="t-dsc-begin">

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;cstdlib&gt;</code> </div>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/rand.html" title="cpp/numeric/random/rand"> <span class="t-lines"><span>rand</span></span></a></div></div>
</td>
<td>  生成伪随机数 <br> <span class="t-mark">(函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/srand.html" title="cpp/numeric/random/srand"> <span class="t-lines"><span>srand</span></span></a></div></div>
</td>
<td>  初始化伪随机数生成器 <br> <span class="t-mark">(函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="random/RAND_MAX.html" title="cpp/numeric/random/RAND MAX"> <span class="t-lines"><span>RAND_MAX</span></span></a></div></div>
</td>
<td>  <span class="t-lc"><a href="random/rand.html" title="cpp/numeric/random/rand">std::rand</a></span> 生成的最大可能值 <br> <span class="t-mark">(宏常量)</span> </td></tr>
</table>
<h3><span class="mw-headline" id=".E7.A4.BA.E4.BE.8B">示例</span></h3>
<div class="t-example"><div class="t-example-live-link"><div class="coliru-btn coliru-btn-run-init">运行此代码</div></div>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="co2">#include &lt;iostream&gt;</span>
<span class="co2">#include &lt;iomanip&gt;</span>
<span class="co2">#include &lt;string&gt;</span>
<span class="co2">#include &lt;map&gt;</span>
<span class="co2">#include &lt;random&gt;</span>
<span class="co2">#include &lt;cmath&gt;</span>
 
<span class="kw4">int</span> main<span class="br0">(</span><span class="br0">)</span>
<span class="br0">{</span>
    <span class="co1">// 以随机值播种，若可能</span>
    <a href="random/random_device.html"><span class="kw1486">std::<span class="me2">random_device</span></span></a> r<span class="sy4">;</span>
 
    <span class="co1">// 选择 1 与 6 间的随机数</span>
    std<span class="sy4">::</span><span class="me2">default_random_engine</span> e1<span class="br0">(</span>r<span class="br0">(</span><span class="br0">)</span><span class="br0">)</span><span class="sy4">;</span>
    <a href="random/uniform_int_distribution.html"><span class="kw1501">std::<span class="me2">uniform_int_distribution</span></span></a><span class="sy1">&lt;</span><span class="kw4">int</span><span class="sy1">&gt;</span> uniform_dist<span class="br0">(</span><span class="nu0">1</span>, <span class="nu0">6</span><span class="br0">)</span><span class="sy4">;</span>
    <span class="kw4">int</span> mean <span class="sy1">=</span> uniform_dist<span class="br0">(</span>e1<span class="br0">)</span><span class="sy4">;</span>
    <a href="../io/cout.html"><span class="kw1757">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> <span class="st0">"Randomly-chosen mean: "</span> <span class="sy1">&lt;&lt;</span> mean <span class="sy1">&lt;&lt;</span> <span class="st0">'<span class="es1">\n</span>'</span><span class="sy4">;</span>
 
    <span class="co1">// 生成围绕平均值的正态分布</span>
    <a href="random/seed_seq.html"><span class="kw1500">std::<span class="me2">seed_seq</span></span></a> seed2<span class="br0">{</span>r<span class="br0">(</span><span class="br0">)</span>, r<span class="br0">(</span><span class="br0">)</span>, r<span class="br0">(</span><span class="br0">)</span>, r<span class="br0">(</span><span class="br0">)</span>, r<span class="br0">(</span><span class="br0">)</span>, r<span class="br0">(</span><span class="br0">)</span>, r<span class="br0">(</span><span class="br0">)</span>, r<span class="br0">(</span><span class="br0">)</span><span class="br0">}</span><span class="sy4">;</span> 
    <a href="random/mersenne_twister_engine.html"><span class="kw1489">std::<span class="me2">mt19937</span></span></a> e2<span class="br0">(</span>seed2<span class="br0">)</span><span class="sy4">;</span>
    <a href="random/normal_distribution.html"><span class="kw1512">std::<span class="me2">normal_distribution</span></span></a><span class="sy1">&lt;&gt;</span> normal_dist<span class="br0">(</span>mean, <span class="nu0">2</span><span class="br0">)</span><span class="sy4">;</span>
 
    <a href="../container/map.html"><span class="kw1281">std::<span class="me2">map</span></span></a><span class="sy1">&lt;</span><span class="kw4">int</span>, <span class="kw4">int</span><span class="sy1">&gt;</span> hist<span class="sy4">;</span>
    <span class="kw1">for</span> <span class="br0">(</span><span class="kw4">int</span> n <span class="sy1">=</span> <span class="nu0">0</span><span class="sy4">;</span> n <span class="sy1">&lt;</span> <span class="nu0">10000</span><span class="sy4">;</span> <span class="sy2">++</span>n<span class="br0">)</span> <span class="br0">{</span>
        <span class="sy2">++</span>hist<span class="br0">[</span><a href="math/round.html"><span class="kw1353">std::<span class="me2">round</span></span></a><span class="br0">(</span>normal_dist<span class="br0">(</span>e2<span class="br0">)</span><span class="br0">)</span><span class="br0">]</span><span class="sy4">;</span>
    <span class="br0">}</span>
    <a href="../io/cout.html"><span class="kw1757">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> <span class="st0">"Normal distribution around "</span> <span class="sy1">&lt;&lt;</span> mean <span class="sy1">&lt;&lt;</span> <span class="st0">":<span class="es1">\n</span>"</span><span class="sy4">;</span>
    <span class="kw1">for</span> <span class="br0">(</span><span class="kw4">auto</span> p <span class="sy4">:</span> hist<span class="br0">)</span> <span class="br0">{</span>
        <a href="../io/cout.html"><span class="kw1757">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> <a href="../io/manip/fixed.html"><span class="kw1783">std::<span class="me2">fixed</span></span></a> <span class="sy1">&lt;&lt;</span> <a href="../io/manip/setprecision.html"><span class="kw1795">std::<span class="me2">setprecision</span></span></a><span class="br0">(</span><span class="nu0">1</span><span class="br0">)</span> <span class="sy1">&lt;&lt;</span> <a href="../io/manip/setw.html"><span class="kw1796">std::<span class="me2">setw</span></span></a><span class="br0">(</span><span class="nu0">2</span><span class="br0">)</span>
                  <span class="sy1">&lt;&lt;</span> p.<span class="me1">first</span> <span class="sy1">&lt;&lt;</span> <span class="st0">' '</span> <span class="sy1">&lt;&lt;</span> <a href="../string/basic_string.html"><span class="kw1230">std::<span class="me2">string</span></span></a><span class="br0">(</span>p.<span class="me1">second</span><span class="sy2">/</span><span class="nu0">200</span>, <span class="st0">'*'</span><span class="br0">)</span> <span class="sy1">&lt;&lt;</span> <span class="st0">'<span class="es1">\n</span>'</span><span class="sy4">;</span>
    <span class="br0">}</span>
<span class="br0">}</span></pre></div></div>
<p>可能的输出：
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="text source-text"><pre class="de1">Randomly-chosen mean: 4
Normal distribution around 4:
-4 
-3 
-2 
-1 
 0 *
 1 ***
 2 ******
 3 ********
 4 *********
 5 ********
 6 ******
 7 ***
 8 *
 9 
10 
11 
12</pre></div></div> 
</div>
<h3><span class="mw-headline" id=".E5.8F.82.E9.98.85">参阅</span></h3>
<table class="t-dsc-begin">

</table>

<!-- 
NewPP limit report
Preprocessor visited node count: 9967/1000000
Preprocessor generated node count: 11659/1000000
Post‐expand include size: 317369/2097152 bytes
Template argument size: 73756/2097152 bytes
Highest expansion depth: 21/40
Expensive parser function count: 0/100
-->

<!-- Saved in parser cache with key mwiki1-mwiki_zh_:pcache:idhash:3155-0!*!0!!zh!*!zh!* and timestamp 20200222100118 -->
</div>                    <!-- /bodycontent -->
                                        <!-- printfooter -->
                    <div class="printfooter">
                    来自“<a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/numeric/random&amp;oldid=61773">https://zh.cppreference.com/mwiki/index.php?title=cpp/numeric/random&amp;oldid=61773</a>”                    </div>
                    <!-- /printfooter -->
                                                            <!-- catlinks -->
                    <!-- /catlinks -->
                                                            <div class="visualClear"></div>
                    <!-- debughtml -->
                                        <!-- /debughtml -->
                </div>
                <!-- /bodyContent -->
            </div>
        </div>
        <!-- /content -->
        <!-- footer -->
        <div id="cpp-footer-base" class="noprint">
            <div id="footer">
                        <div id="cpp-navigation">
            <h5>导航</h5>
            <ul><li><a href="https://zh.cppreference.com/w/cpp/numeric/random">Online version</a></li><li>Offline version retrieved 2020-03-14 18:00.</li></ul></div>
                        <ul id="footer-info">
                                    <li id="footer-info-lastmod"> 本页面最后修改于2019年7月15日 (星期一) 02:23。</li>
                                    <li id="footer-info-viewcount">此页面已被浏览过35,271次。</li>
                            </ul>
                    </div>
        </div>
        <!-- /footer -->
        <script>if(window.mw){
mw.loader.state({"site":"loading","user":"missing","user.groups":"ready"});
}</script>
<script src="../../../common/skin_scripts.js"></script>
<script>if(window.mw){
mw.loader.load(["mediawiki.action.view.postEdit","mediawiki.user","mediawiki.page.ready","mediawiki.searchSuggest","mediawiki.hidpi","ext.gadget.MathJax","ext.gadget.ColiruCompiler"], null, true);
}</script>
<script src="../../../common/site_scripts.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-2828341-1']);
_gaq.push(['_setDomainName', 'cppreference.com']);
_gaq.push(['_trackPageview']);
</script><!-- Served in 1.365 secs. -->
	</body>
<!-- Cached 20200222100118 -->
</html>